package com.pactera.miyuangroup.controller.app;

import com.baomidou.mybatisplus.plugins.Page;
import com.pactera.miyuangroup.filter.CurrentUser;
import com.pactera.miyuangroup.service.LoginUserService;
import com.pactera.miyuangroup.service.ReplenishmentService;
import com.pactera.miyuangroup.vo.request.app.AppReplenishmentReq;
import com.pactera.miyuangroup.vo.response.ResultModel;
import com.pactera.miyuangroup.vo.response.User;
import com.pactera.miyuangroup.vo.response.app.AppMyInformationRes;
import com.pactera.miyuangroup.vo.response.app.AppReplenishmentRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述:
 *
 * @outhor 张汉卿
 * @create 2018-04-27 9:57
 */
@Api(description = "我的信息接口")
@RestController
@RequestMapping("/app/myself")
public class MySelfController {
    @Autowired
    private LoginUserService loginUserService;

    @Autowired
    private ReplenishmentService replenishmentService;

    @ApiOperation(value="我的信息接口", notes="我的信息接口")
    @RequestMapping(value ="/myinformation",method = RequestMethod.POST)
    private ResultModel<AppMyInformationRes> getMmyInformation(@CurrentUser User user){
        AppMyInformationRes myInformationRes = new AppMyInformationRes();
        myInformationRes.setName(user.getUsername());
        myInformationRes.setAccount(user.getName());
        myInformationRes.setJobNumber(user.getJobNumber());
        myInformationRes.setPhone(user.getPhone());
        myInformationRes.setId(user.getId());
        return ResultModel.ok(myInformationRes);
    }


    /*
     * 查询捕获记录列表
     * */

    @ApiOperation(value = "补货记录列表", notes = "补货记录列表")
    @RequestMapping(value = "/getReplenishmentList", method = RequestMethod.POST)
    private ResultModel<Page<AppReplenishmentRes>> getReplenishmentList(@RequestBody AppReplenishmentReq appReplenishmentReq, @CurrentUser User user) {


        Page<AppReplenishmentRes> repList = replenishmentService.getAppReplenishmentList(appReplenishmentReq,user.getId());

        return ResultModel.ok(repList);

    }
}
